/** 
 * @Title: OutSalesModelDAO.java 
 * @Package com.zizo.autohome.carinfo.dao 
 * @Description: TODO
 * @author HeYan
 * @date 2017年1月18日 下午3:43:32 
 */
package com.zizo.autohome.carinfo.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: OutSalesModelDAO
 * @Description: TODO
 * @author HeYan
 * @date 2017年1月18日 下午3:43:32
 * 
 */
public class OutSalesModelDAO {
	private Connection conn;

	public void setSatus(List<String> mids) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < mids.size(); i++) {
			if (i == mids.size() - 1) {
				sb.append(mids.get(i));
			} else {
				sb.append(mids.get(i) + ",");
			}
		}
		String sql = "update autohome_other.other_core_basicparam set bp_status=0 where bp_mid in(" + sb.toString()
				+ ");";
		Statement st = null;
		try {
			st = conn.createStatement();
			st.executeUpdate(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				st.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

	public List<Integer> getIDS() {
		List<Integer> list = new ArrayList<>();
		String sql = "SELECT DISTINCT bp_cid FROM autohome_other.`other_core_basicparam`";
		Statement st = null;
		ResultSet rs = null;
		try {
			st = conn.createStatement();
			rs = st.executeQuery(sql);
			while (rs.next()) {
				list.add(rs.getInt(1));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	public OutSalesModelDAO(Connection conn) {
		super();
		this.conn = conn;
	}

}
